package com.gxa.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.common.R;
import com.gxa.common.vo.AttendanceMonthVo;
import com.gxa.common.vo.AttendancePageRequest;
import com.gxa.entity.AttendanceClock;
import com.gxa.mapper.AttendanceMonthMapper;
import com.gxa.service.AttendanceMonthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class AttendanceMonthServiceImpl implements AttendanceMonthService {

    @Autowired
    AttendanceMonthMapper mapper;

    /**
     * 月报表查询
     * @param attendancePageRequest
     * @return
     */
    @Override
    public R showMonthList(AttendancePageRequest attendancePageRequest) {
        R r = new R();
        Integer currentPage = attendancePageRequest.getPageNum();
        Integer pageSize = attendancePageRequest.getPageSize();

        PageHelper.startPage(currentPage,pageSize);
        List<AttendanceMonthVo> res = mapper.findUserAttendList(attendancePageRequest);

        System.out.println(res);
        PageInfo<AttendanceClock> pageInfo = new PageInfo(res);
        System.out.println(pageInfo.getTotal());

        r.setCode(200);
        r.setMsg("查找成功");
        r.setData(pageInfo);
        return r;
    }
}
